<script setup>
import Menu from "@/component/Menu.vue";
import {userStore} from '@pi/user';
import {onMounted, ref} from "vue";
import {model, removeCookies} from "@ut/tool.js";
import {useRouter} from "vue-router";

let user = userStore();
let vs = ref(false);
let router = useRouter();

onMounted(async () => {
    await user.getInfo();
    if (user.info.state === 1) {
        await model('警告', '账号已锁定，无法使用本系统', 'error', false);
        removeCookies('userInfo');
        router.replace({path: '/login'});
    } else vs.value = true;
})
</script>

<template>
    <div class="index" v-if="vs">
        <Menu />
        <div class="body">
            <div class="router">
                <div class="router_view">
                    <el-scrollbar class="scrollbar">
                        <router-view />
                    </el-scrollbar>
                </div>
            </div>
        </div>
    </div>
</template>

<style scoped lang="less">
.index {
    .size();
    .df();
    .body {
        .size(calc(100% - 200px), 100%);
        .router {
            .size();
            .padd(10px);
            .router_view {
                .size();
                box-shadow: var(--el-box-shadow-light);
                .scrollbar {
                    .size();
                    .padd(10px);
                }
            }
        }
    }
}
/deep/ .el-scrollbar__view {
    .size();
}
</style>